<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
    <meta name="author" content="">
    <title></title>  <link rel="icon" href="/template/pc1/images/wmh_favicon.ico" type="image/x-icon" />
    <% include("../inc/input_css.html"){}%>
    <style>
        .control-label{
            width: 140px!important;
        }
    </style>
    <!--图片编辑器-->
    <link href="/res/plugins/img-viewing/viewer.css" rel="stylesheet">
    <!--图片编辑器-->

</head>
<body>
<div class="ibox">
    <div class="ibox-title">
        <div class="pull-left mbx navbar_title">
            <span class="current">企业信息</span>
            <span class="line">/</span>
            企业认证
        </div>
    </div>
    <div class="ibox-content" id="toastContent">
        <form method="post" action="" class="form-horizontal form-validate">
            <input type="hidden" name="shopId" value="${shopId!}"/>
            <h3 style="text-align: center;margin-bottom: 25px">企业实名认证(审核通过)</h3>
            <h4 style="margin-bottom: 15px" class="padding-40">企业信息登记</h4>
            <hr style="height:1px;border:none;border-top:1px solid #999999;" />
            <div class="form-group">
                <label class="col-sm-2 control-label">品牌名称: </label>
                <div class="col-sm-3">
                    <input type="text" id="brandName" value="${ci.brandName!}" class="form-control light-input" readonly>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">企业名称: </label>
                <div class="col-sm-3">
                    <input type="text" id="company_name" value="${ci.company_name!}" class="form-control light-input" readonly>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">营业执照注册号: </label>
                <div class="col-sm-3">
                    <input type="text" id="business_licence_code" value="${ci.business_licence_code}" class="form-control light-input" readonly>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">营业执照扫描件:</label>
                <div class="col-sm-3">
                    <input type="hidden" id="business_licence_img" value="" class="pull-left form-control light-input"/>
                    <img class="img-rounded docs-pictures clearfix" data-original="${companyInfo.business_licence_img!}" src="${ci.business_licence_img!}" style="max-height:50px;"/>
                </div>
            </div>
            <h4 style="margin-bottom: 15px;margin-top: 50px" class="padding-40">运营者信息登记</h4>
            <hr style="height:1px;border:none;border-top:1px solid #999999;" />
            <div class="form-group">
                <label class="col-sm-2 control-label">邮箱: </label>
                <div class="col-sm-3">
                    <input type="text" id="email" value="${ci.email!}" placeholder="建议用企业邮箱申请" class="form-control light-input" readonly>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">运营者姓名: </label>
                <div class="col-sm-3">
                    <input type="text" id="personInCharge" value="${ci.personInCharge!}" class="form-control light-input" readonly>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">运营者手机号: </label>
                <div class="col-sm-3">
                    <input type="text" id="phone" value="${ci.phone!}" class="form-control light-input" readonly>
                </div>
            </div>

        </form>
    </div>
</div>


<!-- Core  -->
<% include("../inc/input_js.html"){}%>

<!--图片编辑器-->
<script src="/res/plugins/img-viewing/main.js"></script>
<script src="/res/plugins/img-viewing/viewer.js"></script>
<!--图片编辑器-->

<script type="text/javascript">
    var uploadUrl="/file/uploadfile?shopId=${shopId!}&type=d";
    var browserUrl="/file/browser?shopId=${shopId!}";
</script>
<script src="https://static.9hive.cn/global/vendor/file/file.js"></script>
<script type="text/javascript">
    $(function () {
        $("input.browserButton").browser();
    })
</script>
<script>
    $("#sendPhoneCode").on('click', function () {
        var regPhone = /^0?(13[0-9]|15[0-9]|17[0-9]|18[0-9]|14[57])[0-9]{8}$/ ; //手机正则表达式
        var phone=$("#phone").val();
        if(!regPhone.test(phone)){
            layer.msg("请输入正确的手机号!");
            return false;
        }
        $.ajax({
            url: "/shop/companyinfo/getPhoneCode",
            type: 'GET',
            data:{
                "phone": phone
            },
            success: function(data){
                if (data.state=="ok" == true){
                    layer.msg("验证码发送成功");
                    setPhoneTime();
                }else{
                    layer.msg(data.info);
                }
            }});

    });
    var phonetime = 60;
    function setPhoneTime() {
        phonetime--;
        $("#sendPhoneCode").attr('disabled', 'disabled');
        $("#sendPhoneCode").html(phonetime + " s ");
        if (phonetime > 0) {
            setTimeout(setPhoneTime, 1000);
        } else {
            $("#sendPhoneCode").attr('disabled', false);
            $("#sendPhoneCode").html("验证码");
            phonetime = 60;
        }
    }


    //邮箱验证码
    $("#sendEmailCode").on('click', function () {
        var regEmail =/^[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?$/; //邮箱正则表达式
        var email=$("#email").val();
        if(!regEmail.test(email)){
            layer.msg("请输入正确的邮箱格式!");
            return false;
        }

        $.ajax({
            url: "/shop/companyinfo/getEmailCode",
            type: 'GET',
            data:{
                "email": email
            },
            success: function(data){
                if (data.state=="ok" == true){
                    layer.msg("验证码发送成功");
                    setEmailTime();
                }else{
                    layer.msg(data.info);
                }
            }});

    });
    var emailtime = 60;
    function setEmailTime() {
        emailtime--;
        $("#sendEmailCode").attr('disabled', 'disabled');
        $("#sendEmailCode").html(emailtime + " s ");
        if (emailtime > 0) {
            setTimeout(setEmailTime, 1000);
        } else {
            $("#sendEmailCode").attr('disabled', false);
            $("#sendEmailCode").html("验证码");
            emailtime = 60;
        }
    }

    $("#submit").click(function () {
        var company_name=$("#company_name").val();
        var business_licence_code=$("#business_licence_code").val();//
        var business_licence_img=$("#business_licence_img").val();
        var email=$("#email").val();
        var emailCode=$("#emailCode").val();
        var personInCharge=$("#personInCharge").val();
        var phone=$("#phone").val();
        var phoneCode=$("#phoneCode").val();
        var regEmail =/^[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?$/; //邮箱正则表达式
        if(!company_name){
            layer.msg("请填写企业名称!");
            return;
        }
        if(!business_licence_code){
            layer.msg("请填写营业执照注册号!");
            return;
        }
        if(!business_licence_img){
            layer.msg("请上传营业执照扫描件!");
            return;
        }
        if(!regEmail.test(email)){
            layer.msg("请输入正确的邮箱格式!");
            return false;
        }
        if(!emailCode){
            layer.msg("请输入邮箱验证码!");
            return false;
        }
        if(!personInCharge){
            layer.msg("请输入运营者姓名!");
            return false;
        }
        if(!phoneCode){
            layer.msg("请输入短信验证码!");
            return false;
        }
        $.ajax({
            url: "/shop/companyinfo/certificationSave",
            type: 'GET',
            data:{
                "company_name": company_name,
                "business_licence_code": business_licence_code,
                "business_licence_img": business_licence_img,
                "email": email,
                "emailCode": emailCode,
                "personInCharge": personInCharge,
                "phone": phone,
                "phoneCode": phoneCode
            },
            success: function(data){
                if (data.state=="ok" == true){
                    window.location.href="/shop/companyinfo/incertificationForm";
                }else{
                    layer.msg(data.info);
                }
            }});

    });
</script>
</body>
</html>